package project.base.common.config

import org.springframework.boot.web.client.RestTemplateBuilder
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.http.client.ClientHttpRequestFactory
import org.springframework.http.client.SimpleClientHttpRequestFactory
import org.springframework.stereotype.Component
import org.springframework.web.client.RestTemplate

/**
 * redis模板
 * @author 三味
 * @since 2022/3/3 15:23
 */
@Configuration
@Component
open class RestTemplateConfig {

    @Bean
    open fun restTemplate(): RestTemplate? {
        return  RestTemplateBuilder().build()
    }

    @Bean
    open fun simpleClientHttpRequestFactory(): ClientHttpRequestFactory {
        val factory = SimpleClientHttpRequestFactory()
        //单位为ms
        factory.setReadTimeout(5000)
        //单位为ms
        factory.setConnectTimeout(5000)
        return factory
    }
}
